﻿Imports Models.Security

''' <summary>
''' Represent a session in. net
''' </summary>
''' <remarks></remarks>
<Serializable()> _
Public Class ItemSession

    Private _token As String
    Private _userId As Integer
    Private _timeout As Integer
    Private _lastUpdate As DateTime
    Private _openDateTime As DateTime
    'Private _modelData As New ModelData()

    <NonSerialized()> _
    Private _clientSession As ClientSessionVO

    Public Property userId As Integer
        Get
            Return _userId
        End Get
        Set(value As Integer)
            _userId = value
        End Set
    End Property

    Public Property token As String
        Get
            Return _token
        End Get
        Set(value As String)
            _token = value
        End Set
    End Property

    Public Property clientSession() As ClientSessionVO
        Get
            Return _clientSession
        End Get
        Set(ByVal value As ClientSessionVO)
            _clientSession = value
        End Set
    End Property

    Public Property timeout() As Integer
        Get
            Return _timeout
        End Get
        Set(ByVal value As Integer)
            _timeout = value
        End Set
    End Property

    Public Property lastUpdate() As DateTime
        Get
            Return _lastUpdate
        End Get
        Set(ByVal value As DateTime)
            _lastUpdate = value
        End Set
    End Property

    Public Property openDateTime() As DateTime
        Get
            Return _openDateTime
        End Get
        Set(ByVal value As DateTime)
            _openDateTime = value
        End Set
    End Property

    'Public Property modelData() As ModelData
    '    Get
    '        Return _modelData
    '    End Get
    '    Set(ByVal value As ModelData)
    '        _modelData = value
    '    End Set
    'End Property

    Sub New()
    End Sub

    Sub New(sesionVO As Models.Security.ClientSessionVO)
        clientSession = sesionVO
        token = clientSession.token
        userId = clientSession.userId
        lastUpdate = Now
        openDateTime = Now
        timeout = MainLib.Helpers.getConfig("defaultSessionTimeout")
    End Sub

End Class